package com.yichat.micro.msghttpservice.controller;

import com.weibo.api.motan.config.springsupport.BasicRefererConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import com.weibo.api.motan.config.springsupport.annotation.MotanReferer;
import com.yichat.micro.msghttpservice.core.rpc.MsgHttpService;
import com.yichat.micro.msghttpservice.common.vo.MsgHttpRequestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Created by chenmohan on 2019/04/15
 *
 * @description
 */
@RestController
public class TestController {

    @Autowired
    ApplicationContext applicationContext;

    @MotanReferer(basicReferer = "msgHttpServiceBasicRefererConfigBean")
    MsgHttpService msgHttpService;

    @RequestMapping("/http")
    public HashMap<String, String> rpc(MsgHttpRequestVo vo) {
        BasicRefererConfigBean msgHttpServiceBasicRefererConfigBean = applicationContext.getBean("msgHttpServiceBasicRefererConfigBean", BasicRefererConfigBean.class);
      //  RegistryConfigBean registryConfig = applicationContext.getBean("registryConfig", RegistryConfigBean.class);
        return msgHttpService.msgHttp(vo);
    }

}
